'''
A TwistedSim tutorial on how to host asyncore application under TwistedSim.

@author: Hatem Oraby
'''
import twistedSim.simManager as simManager 
from twistedSim.moduleHandler import asyncoreH


def main():
    machine = simManager.Machine()
    #server
    server = simManager.Module('asyncore-example-2', handler = asyncoreH(),
                                nickName = "Asyncore Server")
    simManager.SimManager.addModule(server,machine)
    
    #client
    client = simManager.Module('asyncore-example-1', startTime = 100,
                                handler = asyncoreH(), 
                                nickName = "Asyncore Client")
    simManager.SimManager.addModule(client,machine)
    
    simManager.SimManager.run()

if __name__ == '__main__':
    main()